<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Parameter (computer programming)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Parameter_(computer_programming)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Parameter_computer_programming rootpage-Parameter_computer_programming skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Parameter (computer programming)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">For other uses, see <a href="Parameter_(disambiguation)" class="mw-disambig" title="Parameter (disambiguation)">Parameter (disambiguation)</a>.</div>
<p>In <a href="Computer_programming" title="Computer programming">computer programming</a>, a <b>parameter</b>, a.k.a. <b>formal argument</b>, is a <a href="Variable_(computer_science)" title="Variable (computer science)">variable</a> that represents an argument, a.k.a. actual argument, a.k.a. actual parameter, to a <a href="Subroutine" class="mw-redirect" title="Subroutine">subroutine</a> call.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>a<span class="cite-bracket">]</span></a></sup>.<sup id="cite_ref-Oracle_2-0" class="reference"><a href="#cite_note-Oracle-2"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> A function's <a href="Function_signature" class="mw-redirect" title="Function signature">signature</a> defines its parameters. A call invocation involves evaluating each argument expression of a call and associating the result with the corresponding parameter.
</p><p>For example, consider subroutine <code>def add(x, y): return x + y</code>. Variables <code>x</code> and <code>y</code> are parameters. For call <code>add(2, 3)</code>, the expressions <code>2</code> and <code>3</code> are arguments. For call <code>add(a+1, b+2)</code>, the arguments are <code>a+1</code> and <code>b+2</code>.
</p><p>Parameter passing is defined by a programming language. <a href="Evaluation_strategy" title="Evaluation strategy">Evaluation strategy</a> defines the semantics for how parameters can be declared and how arguments are passed to a subroutine. Generally, with <a href="Call_by_value" class="mw-redirect" title="Call by value">call by value</a>, a parameter acts like a new, <a href="Local_variable" title="Local variable">local variable</a> initialized to the value of the argument. If the argument is a variable, the subroutine cannot modify the argument state because the parameter is a copy. With <a href="Call_by_reference" class="mw-redirect" title="Call by reference">call by reference</a>, which requires the argument to be a variable, the parameter is an alias of the argument.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Example">Example</h2></div>
<p>The following program defines a function named <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">SalesTax</code> with one parameter named <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">price</code>; both typed <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">double</code>.
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">double</span><span class="w"> </span><span class="nf">SalesTax</span><span class="p">(</span><span class="kt">double</span><span class="w"> </span><span class="n">price</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="mf">0.05</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">price</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>For call <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">SalesTax(10.00)</code>, the argument <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">10.00</code> is evaluated to a <a href="Double-precision_floating-point_format" title="Double-precision floating-point format">double</a> value (10) and assigned to parameter variable <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">price</code>. The function is executed and returns the value 0.5.
</p>
<div class="mw-heading mw-heading2"><h2 id="Parameters_and_arguments">Parameters and arguments</h2></div>
<p>The terms <i>parameter</i> and <i>argument</i> may have different meanings in different programming languages. Sometimes they are used interchangeably, and the context is used to distinguish the meaning. The term <i>parameter</i> (sometimes called <i>formal parameter</i>) is often used to refer to the variable as found in the function <a href="Declaration_(computer_programming)" title="Declaration (computer programming)">declaration</a>, while <i>argument</i> (sometimes called <i>actual parameter</i>) refers to the actual input supplied at a function call statement. For example, if one defines a function as <code>def f(x): ...</code>, then <code>x</code> is the parameter, and if it is called by <code>a = ...; f(a)</code> then <code>a</code> is the argument. A parameter is an (unbound) variable, while the argument can be a <a href="Literal_(computer_programming)" title="Literal (computer programming)">literal</a> or variable or more complex expression involving literals and variables. In case of call by value, what is passed to the function is the value of the argument – for example, <code>f(2)</code> and <code>a = 2; f(a)</code> are equivalent calls – while in call by reference, with a variable as argument, what is passed is a reference to that variable - even though the syntax for the function call could stay the same.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> The specification for <a href="Call_by_reference" class="mw-redirect" title="Call by reference">pass-by-reference</a> or <a href="Call_by_value" class="mw-redirect" title="Call by value">pass-by-value</a> would be made in the function declaration and/or definition.
</p><p>Parameters appear in procedure definitions; arguments appear in procedure calls. In the function definition <code>f(x) = x*x</code> the variable <var>x</var> is a parameter; in the function call <code>f(2)</code> the value 2 is the argument of the function. Loosely, a parameter is a type, and an argument is an instance.
</p><p>A parameter is an intrinsic property of the procedure, included in its definition. For example, in many languages, a procedure to add two supplied integers together and calculate the sum would need two parameters, one for each integer. In general, a procedure may be defined with any number of parameters, or no parameters at all. If a procedure has parameters, the part of its definition that specifies the parameters is called its <i>parameter list</i>.
</p><p>By contrast, the arguments are the expressions<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> supplied to the procedure when it is called, usually one expression matching one of the parameters. Unlike the parameters, which form an unchanging part of the procedure's definition, the arguments may vary from call to call. Each time a procedure is called, the part of the procedure call that specifies the arguments is called the <i>argument list</i>.
</p><p>Although parameters are also commonly referred to as arguments, arguments are sometimes thought of as the actual values or references assigned to the parameter variables when the subroutine is called at <a href="Run_time_(program_lifecycle_phase)" class="mw-redirect" title="Run time (program lifecycle phase)">run-time</a>. When discussing code that is calling into a subroutine, any values or references passed into the subroutine are the arguments, and the place in the code where these values or references are given is the <i>parameter list</i>. When discussing the code inside the subroutine definition, the variables in the subroutine's parameter list are the parameters, while the values of the parameters at runtime are the arguments. For example, in C, when dealing with threads it is common to pass in an argument of type void* and cast it to an expected type:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">void</span><span class="w"> </span><span class="nf">ThreadFunction</span><span class="p">(</span><span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="n">pThreadArgument</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="c1">// Naming the first parameter 'pThreadArgument' is correct, rather than</span>
<span class="w"> </span><span class="c1">// 'pThreadParameter'. At run time the value we use is an argument. As</span>
<span class="w"> </span><span class="c1">// mentioned above, reserve the term parameter for when discussing</span>
<span class="w"> </span><span class="c1">// subroutine definitions.</span>
<span class="p">}</span>
</pre></div>
<p>To better understand the difference, consider the following function written in <a href="C_(programming_language)" title="C (programming language)">C</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="nf">Sum</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">addend1</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">addend2</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">addend1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">addend2</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>The function <i>Sum</i> has two parameters, named <i>addend1</i> and <i>addend2</i>. It adds the values passed into the parameters, and returns the result to the subroutine's caller (using a technique automatically supplied by the C compiler).
</p><p>The code which calls the <i>Sum</i> function might look like this:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="n">value1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">40</span><span class="p">;</span>
<span class="kt">int</span><span class="w"> </span><span class="n">value2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span>
<span class="kt">int</span><span class="w"> </span><span class="n">sum_value</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Sum</span><span class="p">(</span><span class="n">value1</span><span class="p">,</span><span class="w"> </span><span class="n">value2</span><span class="p">);</span>
</pre></div>
<p>The variables <i>value1</i> and <i>value2</i> are initialized with values. <i>value1</i> and <i>value2</i> are both arguments to the <i>sum</i> function in this context.
</p><p>At runtime, the values assigned to these variables are passed to the function <i>Sum</i> as arguments. In the <i>Sum</i> function, the parameters <i>addend1</i> and <i>addend2</i> are evaluated, yielding the arguments 40 and 2, respectively. The values of the arguments are added, and the result is returned to the caller, where it is assigned to the variable <i>sum_value</i>.
</p><p>Because of the difference between parameters and arguments, it is possible to supply inappropriate arguments to a procedure. The call may supply too many or too few arguments; one or more of the arguments may be a wrong type; or arguments may be supplied in the wrong order. Any of these situations causes a mismatch between the parameter and argument lists, and the procedure will often return an unintended answer or generate a <a href="Runtime_error" class="mw-redirect" title="Runtime error">runtime error</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Alternative_convention_in_Eiffel">Alternative convention in Eiffel</h3></div>
<p>Within the <a href="Eiffel_(programming_language)" title="Eiffel (programming language)">Eiffel</a> software development method and language, the terms <i>argument</i> and <i>parameter</i> have distinct uses established by convention. The term <i>argument</i> is used exclusively in reference to a routine's inputs,<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> and the term <i>parameter</i> is used exclusively in type parameterization for <a href="Generic_programming" title="Generic programming">generic classes</a>.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</p><p>Consider the following routine definition:
</p>
<div class="mw-highlight mw-highlight-lang-eiffel mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="n">sum</span><span class="w"> </span><span class="p">(</span><span class="n">addend1</span><span class="p">:</span><span class="w"> </span><span class="nc">INTEGER</span><span class="p">;</span><span class="w"> </span><span class="n">addend2</span><span class="p">:</span><span class="w"> </span><span class="nc">INTEGER</span><span class="p">):</span><span class="w"> </span><span class="nc">INTEGER</span>
<span class="w"> </span><span class="kr">do</span>
<span class="w"> </span><span class="kc">Result</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">addend1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">addend2</span>
<span class="w"> </span><span class="kr">end</span>
</pre></div>
<p>The routine <code>sum</code> takes two arguments <code>addend1</code> and <code>addend2</code>, which are called the routine's <b>formal arguments</b>. A call to <code>sum</code> specifies <b>actual arguments</b>, as shown below with <code>value1</code> and <code>value2</code>.
</p>
<div class="mw-highlight mw-highlight-lang-eiffel mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="n">sum_value</span><span class="p">:</span><span class="w"> </span><span class="nc">INTEGER</span>
<span class="w"> </span><span class="n">value1</span><span class="p">:</span><span class="w"> </span><span class="nc">INTEGER</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">40</span>
<span class="w"> </span><span class="n">value2</span><span class="p">:</span><span class="w"> </span><span class="nc">INTEGER</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span>
<span class="w"> </span><span class="err">…</span>
<span class="w"> </span><span class="n">sum_value</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">sum</span><span class="w"> </span><span class="p">(</span><span class="n">value1</span><span class="p">,</span><span class="w"> </span><span class="n">value2</span><span class="p">)</span>
</pre></div>
<p>Parameters are also thought of as either <b>formal</b> or <b>actual</b>. <b>Formal generic parameters</b> are used in the definition of generic classes. In the example below, the class <code>HASH_TABLE</code> is declared as a generic class which has two formal generic parameters, <code>G</code> representing data of interest and <code>K</code> representing the hash key for the data:
</p>
<div class="mw-highlight mw-highlight-lang-eiffel mw-content-ltr" dir="ltr"><pre><span class="kr">class</span><span class="w"> </span><span class="nc">HASH_TABLE</span><span class="w"> </span><span class="o">[</span><span class="nc">G</span><span class="p">,</span><span class="w"> </span><span class="nc">K</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="nc">HASHABLE</span><span class="o">]</span><span class="w"> </span>
<span class="w"> </span><span class="err">…</span>
</pre></div>
<p>When a class becomes a client to <code>HASH_TABLE</code>, the formal generic parameters are substituted with <b>actual generic parameters</b> in a <b>generic derivation</b>. In the following attribute declaration, <code>my_dictionary</code> is to be used as a character string based <a href="Associative_array" title="Associative array">dictionary</a>. As such, both data and key formal generic parameters are substituted with actual generic parameters of type <code>STRING</code>.
</p>
<div class="mw-highlight mw-highlight-lang-eiffel mw-content-ltr" dir="ltr"><pre><span class="w"> </span><span class="n">my_dictionary</span><span class="p">:</span><span class="w"> </span><span class="nc">HASH_TABLE</span><span class="w"> </span><span class="o">[</span><span class="nc">STRING</span><span class="p">,</span><span class="w"> </span><span class="nc">STRING</span><span class="o">]</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Datatypes">Datatypes</h2></div>
<p>In <a href="Strongly_typed_programming_language" class="mw-redirect" title="Strongly typed programming language">strongly typed programming languages</a>, each parameter's <a href="Datatype" class="mw-redirect" title="Datatype">type</a> must be specified in the procedure declaration. Languages using <a href="Type_inference" title="Type inference">type inference</a> attempt to discover the types automatically from the function's body and usage. Dynamically typed programming languages defer type resolution until run-time. Weakly typed languages perform little to no type resolution, relying instead on the programmer for correctness.
</p><p>Some languages use a special keyword (e.g. <i>void</i>) to indicate that the subroutine has no parameters; in formal <a href="Type_theory" title="Type theory">type theory</a>, such functions take an empty parameter list (whose type is not <i>void</i>, but rather <i><a href="Unit_type" title="Unit type">unit</a></i>).
</p>
<div class="mw-heading mw-heading2"><h2 id="Argument_passing">Argument passing</h2></div>
<p>The exact mechanism for assigning arguments to parameters, called <i>argument passing</i>, depends upon the <a href="Evaluation_strategy" title="Evaluation strategy">evaluation strategy</a> used for that parameter (typically <a href="Call_by_value" class="mw-redirect" title="Call by value">call by value</a>), which may be specified using keywords.
</p>
<div class="mw-heading mw-heading3"><h3 id="Default_arguments">Default arguments</h3></div>
<p>Some programming languages such as <a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a>, <a href="C%2B%2B" title="C++">C++</a>, <a href="Clojure" title="Clojure">Clojure</a>, <a href="Common_Lisp" title="Common Lisp">Common Lisp</a>,<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> <a href="Fortran_90" class="mw-redirect" title="Fortran 90">Fortran 90</a>,<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> <a href="Python_(programming_language)" title="Python (programming language)">Python</a>, <a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a>, <a href="Tcl_(programming_language)" class="mw-redirect" title="Tcl (programming language)">Tcl</a>, and <a href="Windows_PowerShell" class="mw-redirect" title="Windows PowerShell">Windows PowerShell</a> allow for a <a href="Default_argument" title="Default argument">default argument</a> to be explicitly or implicitly given in a subroutine's declaration. This allows the caller to omit that argument when calling the subroutine. If the default argument is explicitly given, then that value is used if it is not provided by the caller. If the default argument is implicit (sometimes by using a keyword such as <i>Optional</i>) then the language provides a well-known value (such as <i><a href="Null_pointer" title="Null pointer">null</a></i>, <i>Empty</i>, zero, an empty string, etc.) if a value is not provided by the caller.
</p><p>PowerShell example:
</p>
<div class="mw-highlight mw-highlight-lang-powershell mw-content-ltr" dir="ltr"><pre><span class="k">function</span> <span class="n">doc</span><span class="p">(</span><span class="nv">$g</span> <span class="p">=</span> <span class="n">1</span><span class="p">.</span><span class="n">21</span><span class="p">)</span> <span class="p">{</span>
<span class="s2">"$g gigawatts? $g gigawatts? Great Scott!"</span>
<span class="p">}</span>
</pre></div>
<div class="mw-highlight mw-highlight-lang-ps1con mw-content-ltr" dir="ltr"><pre><span class="gp">PS > </span><span class="n">doc</span>
<span class="go">1.21 gigawatts? 1.21 gigawatts? Great Scott!</span>
<span class="gp">PS > </span><span class="n">doc</span> <span class="n">88</span>
<span class="go">88 gigawatts? 88 gigawatts? Great Scott!</span>
</pre></div>
<p>Default arguments can be seen as a special case of the variable-length argument list.
</p>
<div class="mw-heading mw-heading3"><h3 id="Variable-length_parameter_lists">Variable-length parameter lists</h3></div>
<p>Some languages allow subroutines to be defined to accept a <a href="Variadic_function" title="Variadic function">variable number of arguments</a>. For such languages, the subroutines must iterate through the list of arguments.
</p><p>PowerShell example:
</p>
<div class="mw-highlight mw-highlight-lang-powershell mw-content-ltr" dir="ltr"><pre><span class="k">function</span> <span class="n">marty</span> <span class="p">{</span>
<span class="nv">$args</span> <span class="p">|</span> <span class="k">foreach</span> <span class="p">{</span> <span class="s2">"back to the year $_"</span> <span class="p">}</span>
<span class="p">}</span>
</pre></div>
<div class="mw-highlight mw-highlight-lang-ps1con mw-content-ltr" dir="ltr"><pre><span class="gp">PS > </span><span class="n">marty</span> <span class="n">1985</span>
<span class="go">back to the year 1985</span>
<span class="gp">PS > </span><span class="n">marty</span> <span class="n">2015</span> <span class="n">1985</span> <span class="n">1955</span>
<span class="go">back to the year 2015</span>
<span class="go">back to the year 1985</span>
<span class="go">back to the year 1955</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Named_parameters">Named parameters</h3></div>
<p>Some programming languages—such as <a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a> and <a href="Windows_PowerShell" class="mw-redirect" title="Windows PowerShell">Windows PowerShell</a>—allow subroutines to have <a href="Named_parameter" title="Named parameter">named parameters</a>. This allows the calling code to be more <a href="Self-documenting" class="mw-redirect" title="Self-documenting">self-documenting</a>. It also provides more flexibility to the caller, often allowing the order of the arguments to be changed, or for arguments to be omitted as needed.
</p><p>PowerShell example:
</p>
<div class="mw-highlight mw-highlight-lang-powershell mw-content-ltr" dir="ltr"><pre><span class="k">function</span> <span class="n">jennifer</span><span class="p">(</span><span class="nv">$adjectiveYoung</span><span class="p">,</span> <span class="nv">$adjectiveOld</span><span class="p">)</span> <span class="p">{</span>
<span class="s2">"Young Jennifer: I'm $adjectiveYoung!"</span>
<span class="s2">"Old Jennifer: I'm $adjectiveOld!"</span>
<span class="p">}</span>
</pre></div>
<div class="mw-highlight mw-highlight-lang-ps1con mw-content-ltr" dir="ltr"><pre><span class="gp">PS > </span><span class="n">jennifer</span> <span class="s1">'fresh'</span> <span class="s1">'experienced'</span>
<span class="go">Young Jennifer: I'm fresh!</span>
<span class="go">Old Jennifer: I'm experienced!</span>
<span class="gp">PS > </span><span class="n">jennifer</span> <span class="n">-adjectiveOld</span> <span class="s1">'experienced'</span> <span class="n">-adjectiveYoung</span> <span class="s1">'fresh'</span>
<span class="go">Young Jennifer: I'm fresh!</span>
<span class="go">Old Jennifer: I'm experienced!</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Multiple_parameters_in_functional_languages">Multiple parameters in functional languages</h3></div>
<p>In <a href="Lambda_calculus" title="Lambda calculus">lambda calculus</a>, each function has exactly one parameter. What is thought of as functions with multiple parameters is usually represented in lambda calculus as a function which takes the first argument, and returns a function which takes the rest of the arguments; this is a transformation known as <a href="Currying" title="Currying">currying</a>. Some programming languages, like <a href="ML_(programming_language)" title="ML (programming language)">ML</a> and <a href="Haskell_(programming_language)" class="mw-redirect" title="Haskell (programming language)">Haskell</a>, follow this scheme. In these languages, every function has exactly one parameter, and what may look like the definition of a function of multiple parameters, is actually <a href="Syntactic_sugar" title="Syntactic sugar">syntactic sugar</a> for the definition of a function that returns a function, etc. <a href="Function_application" title="Function application">Function application</a> is <a href="Operator_associativity" title="Operator associativity">left-associative</a> in these languages as well as in lambda calculus, so what looks like an application of a function to multiple arguments is correctly evaluated as the function applied to the first argument, then the resulting function applied to the second argument, etc.
</p>
<div class="mw-heading mw-heading2"><h2 id="Output_parameters">Output parameters</h2></div>
<p>An <b>output parameter</b>, also known as an <b>out parameter</b> or <b>return parameter</b>, is a parameter used for output, rather than the more usual use for input. Using <a href="Call_by_reference" class="mw-redirect" title="Call by reference">call by reference</a> parameters, or call by value parameters where the value is a reference, as output parameters is an idiom in some languages, notably C and C++,<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>b<span class="cite-bracket">]</span></a></sup> while other languages have built-in support for output parameters. Languages with built-in support for output parameters include <a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a><sup id="cite_ref-ada_13-0" class="reference"><a href="#cite_note-ada-13"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> (see <a href="https://en.wikibooks.org/wiki/Ada_Programming/Subprograms" class="extiw external" title="b:Ada Programming/Subprograms">Ada subprograms</a>), <a href="Fortran" title="Fortran">Fortran</a> (since <a href="Fortran_90" class="mw-redirect" title="Fortran 90">Fortran 90</a>; see <a href="https://en.wikibooks.org/wiki/Fortran/Fortran_procedures_and_functions#Intent" class="extiw external" title="b:Fortran/Fortran procedures and functions">Fortran "intent"</a>), various procedural extensions to <a href="SQL" title="SQL">SQL</a>, such as <a href="PL/SQL" title="PL/SQL">PL/SQL</a> (see <a href="PL/SQL#Functions" title="PL/SQL">PL/SQL functions</a>)<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> and <a href="Transact-SQL" title="Transact-SQL">Transact-SQL</a>, <a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a><sup id="cite_ref-hallam_15-0" class="reference"><a href="#cite_note-hallam-15"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> and the <a href=".NET_Framework" title=".NET Framework">.NET Framework</a>,<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> <a href="Swift_(programming_language)" title="Swift (programming language)">Swift</a>,<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup> and the scripting language <a href="TScript" title="TScript">TScript</a> (see <a href="TScript#Function_declarations" title="TScript">TScript function declarations</a>).
</p><p>More precisely, one may distinguish three types of parameters or <b>parameter modes</b>: <i><style data-mw-deduplicate="TemplateStyles:r1238216509">
/* start https://en.wikipedia.org/ */
.mw-parser-output .vanchor>:target~.vanchor-text{background-color:#b1d2ff}@media screen{html.skin-theme-clientpref-night .mw-parser-output .vanchor>:target~.vanchor-text{background-color:#0f4dc9}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .vanchor>:target~.vanchor-text{background-color:#0f4dc9}}
/* end https://en.wikipedia.org/ */
</style><span class="vanchor"><span class="vanchor-text">input parameter</span></span>s</i>, <i>output parameters,</i> and <i><span class="vanchor"><span class="vanchor-text">input/output parameter</span></span>s;</i> these are often denoted <code>in</code>, <code>out</code>, and <code>in out</code> or <code>inout</code>. An input argument (the argument to an input parameter) must be a value, such as an initialized variable or literal, and must not be redefined or assigned to; an output argument must be an assignable variable, but it need not be initialized, any existing value is not accessible, and must be assigned a value; and an input/output argument must be an initialized, assignable variable, and can optionally be assigned a value. The exact requirements and enforcement vary between languages – for example, in <a href="Ada_83" class="mw-redirect" title="Ada 83">Ada 83</a> output parameters can only be assigned to, not read, even after assignment (this was removed in <a href="Ada_95" class="mw-redirect" title="Ada 95">Ada 95</a> to remove the need for an auxiliary accumulator variable). These are analogous to the notion of a <a href="Value_(computer_science)" title="Value (computer science)">value</a> in an expression being an r-value (has a value), an l-value (can be assigned), or an r-value/l-value (has a value and can be assigned), respectively, though these terms have specialized meanings in C.
</p><p>In some cases only input and input/output are distinguished, with output being considered a specific use of input/output, and in other cases only input and output (but not input/output) are supported. The default mode varies between languages: in Fortran 90 input/output is default, while in C# and SQL extensions input is default, and in TScript each parameter is explicitly specified as input or output.
</p><p>Syntactically, parameter mode is generally indicated with a keyword in the function declaration, such as <code>void f(out int x)</code> in C#. Conventionally output parameters are often put at the end of the parameter list to clearly distinguish them, though this is not always followed. TScript uses a different approach, where in the function declaration input parameters are listed, then output parameters, separated by a colon (:) and there is no return type to the function itself, as in this function, which computes the size of a text fragment:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="n">TextExtent</span><span class="p">(</span><span class="n">WString</span><span class="w"> </span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="n">Font</span><span class="w"> </span><span class="n">font</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">Integer</span><span class="w"> </span><span class="n">width</span><span class="p">,</span><span class="w"> </span><span class="n">Integer</span><span class="w"> </span><span class="n">height</span><span class="p">)</span>
</pre></div>
<p>Parameter modes are a form of <a href="Denotational_semantics" title="Denotational semantics">denotational semantics</a>, stating the programmer's intent and allowing compilers to catch errors and apply optimizations – they do not necessarily imply <a href="Operational_semantics" title="Operational semantics">operational semantics</a> (how the parameter passing actually occurs). Notably, while input parameters can be implemented by call by value, and output and input/output parameters by call by reference – and this is a straightforward way to implement these modes in languages without built-in support – this is not always how they are implemented. This distinction is discussed in detail in the <i>Ada '83 Rationale,</i> which emphasizes that the parameter mode is abstracted from which parameter passing mechanism (by reference or by copy) is actually implemented.<sup id="cite_ref-ada_13-1" class="reference"><a href="#cite_note-ada-13"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> For instance, while in C# input parameters (default, no keyword) are passed by value, and output and input/output parameters (<code>out</code> and <code>ref</code>) are passed by reference, in PL/SQL input parameters (<code>IN</code>) are passed by reference, and output and input/output parameters (<code>OUT</code> and <code>IN OUT</code>) are by default passed by value and the result copied back, but can be passed by reference by using the <code>NOCOPY</code> compiler hint.<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</p><p>A syntactically similar construction to output parameters is to assign the <a href="Return_value" class="mw-redirect" title="Return value">return value</a> to a variable with the same name as the function. This is found in <a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a> and <a href="Fortran_66" class="mw-redirect" title="Fortran 66">Fortran 66</a> and <a href="Fortran_77" class="mw-redirect" title="Fortran 77">Fortran 77</a>, as in this Pascal example:
</p>
<div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span class="k">function</span><span class="w"> </span><span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="o">,</span><span class="w"> </span><span class="n">y</span><span class="o">:</span><span class="w"> </span><span class="kt">integer</span><span class="p">)</span><span class="o">:</span><span class="w"> </span><span class="kt">integer</span><span class="o">;</span>
<span class="k">begin</span>
<span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">y</span><span class="o">;</span>
<span class="k">end</span><span class="o">;</span>
</pre></div>
<p>This is semantically different in that when called, the function is simply evaluated – it is not passed a variable from the calling <a href="Scope_(computer_science)" title="Scope (computer science)">scope</a> to store the output in.
</p>
<div class="mw-heading mw-heading3"><h3 id="Use">Use</h3></div>
<p>The primary use of output parameters is to return multiple values from a function, while the use of input/output parameters is to modify state using parameter passing (rather than by shared environment, as in global variables). An important use of returning multiple values is to solve the <a href="Semipredicate_problem" title="Semipredicate problem">semipredicate problem</a> of returning both a value and an error status – see <a href="Semipredicate_problem#Multivalued_return" title="Semipredicate problem">Semipredicate problem: Multivalued return</a>.
</p><p>For example, to return two variables from a function in C, one may write:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="n">width</span>
<span class="kt">int</span><span class="w"> </span><span class="n">height</span><span class="p">;</span>
<span class="n">F</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">width</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">height</span><span class="p">);</span>
</pre></div>
<p>where <code>x</code> is an input parameter and <code>width</code> and <code>height</code> are output parameters.
</p><p>A common use case in C and related languages is for <a href="Exception_handling" title="Exception handling">exception handling</a>, where a function places the return value in an output variable, and returns a Boolean corresponding to whether the function succeeded or not. An archetypal example is the <code>TryParse</code> method in .NET, especially C#, which parses a string into an integer, returning <code>true</code> on success and <code>false</code> on failure. This has the following signature:<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span class="k">public</span><span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="kt">bool</span><span class="w"> </span><span class="nf">TryParse</span><span class="p">(</span><span class="kt">string</span><span class="w"> </span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="k">out</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">result</span><span class="p">)</span>
</pre></div>
<p>and may be used as follows:
</p>
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="n">result</span><span class="p">;</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="n">Int32</span><span class="p">.</span><span class="n">TryParse</span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">result</span><span class="p">))</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// exception handling</span>
<span class="p">}</span>
</pre></div>
<p>Similar considerations apply to returning a value of one of several possible types, where the return value can specify the type and then value is stored in one of several output variables.
</p>
<div class="mw-heading mw-heading3"><h3 id="Drawbacks">Drawbacks</h3></div>
<p>Output parameters are often discouraged in modern programming, essentially as being awkward, confusing, and too low-level – commonplace return values are considerably easier to understand and work with.<sup id="cite_ref-CA1021_20-0" class="reference"><a href="#cite_note-CA1021-20"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup> Notably, output parameters involve functions with side effects (modifying the output parameter) and are semantically similar to references, which are more confusing than pure functions and values, and the distinction between output parameters and input/output parameters can be subtle. Further, since in common programming styles most parameters are simply input parameters, output parameters and input/output parameters are unusual and hence susceptible to misunderstanding.
</p><p>Output and input/output parameters prevent <a href="Function_composition_(computer_science)" title="Function composition (computer science)">function composition</a>, since the output is stored in variables, rather than in the value of an expression. Thus one must initially declare a variable, and then each step of a chain of functions must be a separate statement. For example, in C++ the following function composition:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="n">Object</span><span class="w"> </span><span class="n">obj</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">G</span><span class="p">(</span><span class="n">y</span><span class="p">,</span><span class="w"> </span><span class="n">F</span><span class="p">(</span><span class="n">x</span><span class="p">));</span>
</pre></div>
<p>when written with output and input/output parameters instead becomes (for <code>F</code> it is an output parameter, for <code>G</code> an input/output parameter):
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="n">Object</span><span class="w"> </span><span class="n">obj</span><span class="p">;</span>
<span class="n">F</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">obj</span><span class="p">);</span>
<span class="n">G</span><span class="p">(</span><span class="n">y</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">obj</span><span class="p">);</span>
</pre></div>
<p>In the special case of a function with a single output or input/output parameter and no return value, function composition is possible if the output or input/output parameter (or in C/C++, its address) is also returned by the function, in which case the above becomes:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="n">Object</span><span class="w"> </span><span class="n">obj</span><span class="p">;</span>
<span class="n">G</span><span class="p">(</span><span class="n">y</span><span class="p">,</span><span class="w"> </span><span class="n">F</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="o">&</span><span class="n">obj</span><span class="p">));</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Alternatives">Alternatives</h3></div>
<p>There are various alternatives to the use cases of output parameters.
</p><p>For returning multiple values from a function, an alternative is to return a <a href="Tuple" title="Tuple">tuple</a>. Syntactically this is clearer if automatic sequence unpacking and <a href="Parallel_assignment" class="mw-redirect" title="Parallel assignment">parallel assignment</a> can be used, as in <a href="Go_(programming_language)" title="Go (programming language)">Go</a> or Python, such as:
</p>
<div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span class="k">def</span><span class="w"> </span><span class="nf">f</span><span class="p">():</span>
<span class="k">return</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span>
<span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">=</span> <span class="n">f</span><span class="p">()</span>
</pre></div>
<p>For returning a value of one of several types, a <a href="Tagged_union" title="Tagged union">tagged union</a> can be used instead; the most common cases are <a href="Nullable_type" title="Nullable type">nullable types</a> (<a href="Option_type" title="Option type">option types</a>), where the return value can be null to indicate failure. For exception handling, one can return a nullable type, or raise an exception. For example, in Python one might have either:
</p>
<div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span class="n">result</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
<span class="k">if</span> <span class="n">result</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="c1"># exception handling</span>
</pre></div>
<p>or, more idiomatically:
</p>
<div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span class="k">try</span><span class="p">:</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span>
<span class="c1"># exception handling</span>
</pre></div>
<p>The micro-optimization of not requiring a local variable and copying the return when using output variables can also be applied to conventional functions and return values by sufficiently sophisticated compilers.
</p><p>The usual alternative to output parameters in C and related languages is to return a single <a href="Data_structure" title="Data structure">data structure</a> containing all return values.<sup id="cite_ref-hallam_15-1" class="reference"><a href="#cite_note-hallam-15"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> For example, given a structure encapsulating width and height, one can write:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">WidthHeight</span><span class="w"> </span><span class="n">width_and_height</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">F</span><span class="p">(</span><span class="n">x</span><span class="p">);</span>
</pre></div>
<p>In object-oriented languages, instead of using input/output parameters, one can often use <a href="Call_by_sharing" class="mw-redirect" title="Call by sharing">call by sharing</a>, passing a reference to an object and then mutating the object, though not changing which object the variable refers to.<sup id="cite_ref-CA1021_20-1" class="reference"><a href="#cite_note-CA1021-20"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Command-line_argument" class="mw-redirect" title="Command-line argument">Command-line argument</a></li>
<li><a href="Evaluation_strategy" title="Evaluation strategy">Evaluation strategy</a></li>
<li><a href="Operator_overloading" title="Operator overloading">Operator overloading</a></li>
<li><a href="Free_variables_and_bound_variables" title="Free variables and bound variables">Free variables and bound variables</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist reflist-lower-alpha">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">In this article, the term "subroutine" refers to any subroutine-like construct, which have different names and slightly different meanings depending on the <a href="Programming_language" title="Programming language">programming language</a> being discussed.</span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text">C and C++ are call by value, but if type is a reference (a C/C++ pointer or C++ reference), then setting the value of the reference can be used to produce call by reference style behavior.</span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-Oracle-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-Oracle_2-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">"Passing Information to a Method or a Constructor (Learning the Java Language > Classes and Objects)"</a>. <i>The Java™ Tutorials</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2021-09-09</span></span>. <q>Parameters refers to the list of variables in a method declaration. Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the arguments used must match the declaration's parameters in type and order.</q></cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFPrata2004" class="citation book cs1">Prata, Stephen (2004). <i>C primer plus</i> (5th ed.). Sams. pp. <span class="nowrap">276–</span>277. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-672-32696-7</bdi>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20051214034042/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf">"Working Draft, Standard for Programming Language C++"</a> <span class="cs1-format">(PDF)</span>. <i>Open Standards</i>. 2005-10-19. Archived from <a rel="nofollow" class="external text" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf">the original</a> <span class="cs1-format">(PDF)</span> on December 14, 2005<span class="reference-accessdate">. Retrieved <span class="nowrap">1 January</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite id="CITEREFGordon" class="citation web cs1">Gordon, Aaron. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20180101140104/http://rowdysites.msudenver.edu/~gordona/cs3210/lects/lect10.html">"Subprograms and Parameter Passing"</a>. <i>rowdysites.msudenver.edu/~gordona</i>. Archived from <a rel="nofollow" class="external text" href="http://rowdysites.msudenver.edu/~gordona/cs3210/lects/lect10.html">the original</a> on 1 January 2018<span class="reference-accessdate">. Retrieved <span class="nowrap">1 January</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFDollard" class="citation web cs1">Dollard, Kathleen. <a rel="nofollow" class="external text" href="https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/passing-arguments-by-value-and-by-reference">"Passing Arguments by Value and by Reference (Visual Basic)"</a>. <i>Microsoft Learn</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2018-10-27</span></span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://crasseux.com/books/ctutorial/Actual-parameters-and-formal-parameters.html">"The GNU C Programming Tutorial"</a>. <i>crasseux.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2018-10-27</span></span>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">Meyer, Bertrand. <i><a href="Object-Oriented_Software_Construction" title="Object-Oriented Software Construction">Object-Oriented Software Construction</a>, 2nd Edition,</i> Prentice Hall, 1997, p 444.</span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text">Meyer, p. 96.</span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://gigamonkeys.com/book/functions.html">"Functions"</a>. <i>gigamonkeys.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2021-06-02</span></span>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.netlib.org/ccm/page/api/optional.html">"optional arguments"</a>. <i>www.netlib.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2021-06-02</span></span>.</cite></span>
</li>
<li id="cite_note-ada-13"><span class="mw-cite-backlink">^ <a href="#cite_ref-ada_13-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-ada_13-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://archive.adaic.com/standards/83rat/html/ratl-08-02.html">8.2 Parameter Modes</a>, "<a rel="nofollow" class="external text" href="http://archive.adaic.com/standards/83rat/html/Welcome.html">Rationale for the Design of the Ada® Programming Language</a>"</span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://docs.oracle.com/cd/B10500_01/appdev.920/a96624/08_subs.htm#895">8. PL/SQL Subprograms: Specifying Subprogram Parameter Modes</a></span>
</li>
<li id="cite_note-hallam-15"><span class="mw-cite-backlink">^ <a href="#cite_ref-hallam_15-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-hallam_15-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFPeter_Hallam" class="citation web cs1">Peter Hallam. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110926113834/http://msdn.microsoft.com/en-us/vcsharp/aa336814.aspx">"Why does C# have both 'ref' and 'out'?"</a>. Archived from <a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/vcsharp/aa336814.aspx">the original</a> on 2011-09-26.</cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/system.data.parameterdirection.aspx">ParameterDirection Enumeration</a></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://docs.swift.org/swift-book/LanguageGuide/Functions.html">Functions — The Swift Programming Language (Swift 4.2)</a></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://docs.oracle.com/cd/B10500_01/appdev.920/a96624/08_subs.htm#12813">8. PL/SQL Subprograms: Passing Large Data Structures with the NOCOPY Compiler Hint</a></span>
</li>
<li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/f02979c7.aspx">Int32.TryParse Method (String, Int32)</a></span>
</li>
<li id="cite_note-CA1021-20"><span class="mw-cite-backlink">^ <a href="#cite_ref-CA1021_20-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-CA1021_20-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/ms182131.aspx">CA1021: Avoid out parameters</a></span>
</li>
</ol></div></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-05-09" href="https://en.wikipedia.org/wiki/?title=Parameter_(computer_programming)&oldid=1289563793">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>